package com.itbour.web.action.trade;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.itbour.com.page.Page;
import com.itbour.common.base.BaseAction;
import com.itbour.common.util.StringUtils;
import com.itbour.dto.com.UserInfoDto;
import com.itbour.dto.trade.PayInfoDto;
import com.itbour.service.trade.OrderStateHisInfoService;
import com.opensymphony.xwork2.ActionContext;

/**
 * 订单状态历史一览
 * @author 李琦  2017
 */

public class GetOrderStateHisInfoAction extends BaseAction{

	/**
	 */
	private static final long serialVersionUID = 1L;
	private OrderStateHisInfoService orderStateHisInfoService;
	private HashMap<String, Object> resMap = new HashMap<String, Object>();
	private List<PayInfoDto> listRPay;
	private String findObjId;//交易对象ID
	private String findHisId;//支付记录ID
	private String findType;//支付东西分类
	private String findDateStart;//起始时间
	private String findDateEnd;//结束时间
	
	public String pageOrderStatehisInfo(){
		Map<String, Object> session = ActionContext.getContext().getSession();
		UserInfoDto user = (UserInfoDto)session.get("user");
		HttpServletRequest request = ServletActionContext.getRequest();
		Integer pageNo = Integer.parseInt(request.getParameter("page"));
		Integer pageSize = Integer.parseInt(request.getParameter("rows"));
		if(user!=null && user.getUser_id()!=null && pageNo!=null && pageSize!=null){
			Map<String, Object> parm = new HashMap<String, Object>();
			if(StringUtils.isNotEmpty(findDateEnd)){//结束时间
				parm.put("endTime",findDateEnd);
			}
			if(StringUtils.isNotEmpty(findDateStart)){//起始时间
				parm.put("startTime",findDateStart);
			}
			if(StringUtils.isNotEmpty(findType)){//支付东西分类
				parm.put("type",findType);
			}
			if(StringUtils.isNotEmpty(findHisId)){//支付记录ID
				parm.put("his_id",findHisId);
			}
			if(StringUtils.isNotEmpty(findObjId)){//支付交易对象编号
				parm.put("trade_obj_id",findObjId);
			}
			Page page = orderStateHisInfoService.pageOrderStateHisInfo(parm, pageNo, pageSize);
			resMap.put("total", page.getTotalCount());
			resMap.put("rows", page.getResult());
		}
		return SUCCESS;
	}

	
	
	
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public HashMap<String, Object> getResMap() {
		return resMap;
	}
	public void setResMap(HashMap<String, Object> resMap) {
		this.resMap = resMap;
	}

	public List<PayInfoDto> getListRPay() {
		return listRPay;
	}
	public void setListRPay(List<PayInfoDto> listRPay) {
		this.listRPay = listRPay;
	}
	public String getFindHisId() {
		return findHisId;
	}

	public void setFindHisId(String findHisId) {
		this.findHisId = findHisId;
	}
	public String getFindType() {
		return findType;
	}
	public void setFindType(String findType) {
		this.findType = findType;
	}
	public String getFindDateStart() {
		return findDateStart;
	}

	public void setFindDateStart(String findDateStart) {
		this.findDateStart = findDateStart;
	}
	public String getFindDateEnd() {
		return findDateEnd;
	}
	public void setFindDateEnd(String findDateEnd) {
		this.findDateEnd = findDateEnd;
	}
	public String getFindObjId() {
		return findObjId;
	}
	public void setFindObjId(String findObjId) {
		this.findObjId = findObjId;
	}
	public OrderStateHisInfoService getOrderStateHisInfoService() {
		return orderStateHisInfoService;
	}
	public void setOrderStateHisInfoService(
			OrderStateHisInfoService orderStateHisInfoService) {
		this.orderStateHisInfoService = orderStateHisInfoService;
	}
}
